<div class="rankedBenefits">
<form method="post" noLoading="true" regularPost="true">
<?php
$entities = getInputArray("entities", $params, array());
$from = getInputArray("from", $params, array());
$to = getInputArray("to", $params, array());

//
echo "<div class='box_search'>";
echo loadView("input/date",array("name"=>"from", "value"=> $from, "text"=>langEcho("from"),"required" => false));
echo "</div>";
echo "<div class='box_search'>";
echo loadView("input/date",array("name"=>"to", "value" => $to, "text"=>langEcho("to"), "required" => false));
echo "</div>";
echo loadView("input/submit",array("value"=>langEcho("search")));
?>
</form>
</div>

<div class="clearFloat"></div>
<div id='reportContent'></div>
<table class="report_table">
<tr class="header_report_row">
	<td class="header_report_column">
		<?php echo langEcho("name") ?>
	</td>
	<td class="header_report_column">
		<?php echo langEcho("company") ?>
	</td>
	<td class="header_report_column">
		<?php echo langEcho("likes") ?>
	</td>

</tr>
<?php

$maxValue = 0;
$values = array();
foreach($entities as $entity){
	$values[$entity->attributes->name] = $entity->attributes->likes;
	if($entity->attributes->likes > $maxValue){
		$maxValue = $entity->attributes->likes;
	}
?>
	<tr class="report_row">
		<td class="report_column">
			<?php
				echo $entity->attributes->name;
			?>
		</td>
		<td class="report_column">
			<?php echo $entity->attributes->company;?>
		</td>
		<td class="report_column">
			<?php echo $entity->attributes->likes; ?>
		</td>
	</tr>
<?
}
?>
</table>

<div style="margin-top:20px">

<?php
$chart = new GoogChart();
$data = array();
foreach ($values as $key => $value){
	$data[$key] = array($value / $maxValue * 100);
}

$chart->setChartAttrs( array(
	'type' => 'bar-vertical',
	'data' => $data,
	'LabelsXY'=> true,
	'size' => array( 400, 300 ),
	'maxRangeValue' => $maxValue,
	'color' => $chart->generateRandomColors(sizeof($data)),
	'fill' => array_values($values),
));

// Print chart
echo $chart;

?>
</div>
